import logging
from celery_tasks.main import app
from celery_tasks.sms import constants
from celery_tasks.sms.yuntongxun.sms import CCP


logger = logging.getLogger('django')


@app.task(name='send_sms_code')
def send_sms_code(mobile, sms_code):
    # 调用第三方工具发送短信验证码
    ccp = CCP()
    ccp.send_template_sms(mobile, [sms_code, constants.SMS_CODE_REDIS_EXPIRES // 60],
                          constants.SEND_SMS_TEMPLATE_ID)
    logger.debug({'%s:%s' % (mobile, sms_code)})
